/*
 * bencoder.h
 *
 *  Created on: 04/07/2009
 *      Author: andre
 */

#ifndef BENCODER_H_
#define BENCODER_H_

#include "aatracker.h"

#define MINIMAL_RESPONSE_LENGTH 55
#define MINIMAL_ERROR_MESSAGE_LENGTH 21
#define PEER_LIST_IS_NULL -1
#define BENCODED_RESPONSE_CONTAINER_IS_NULL -2
#define ERROR_CREATING_BENCODED_RESPONSE -3
#define PARAMETER_IS_NULL -4
#define ERROR_BENCODING_ERROR_MESSAGE -5

typedef struct announceresults {

    int complete;
    int incomplete;
    int numberOfPeers;
    char peers[MAX_PEERS_IN_RESPONSE *6];
} AnnounceResults;

typedef struct bencodedresp {

    char str[(MAX_PEERS_IN_RESPONSE *6) +70 ];
    int bencodedResponseLength;
} BencodedResponse;

int bencodeAnnounceResponse(AnnounceResults *tr, BencodedResponse *br);

int bencodeErrorMessage(char *errorMessage, BencodedResponse *br);

#endif /* BENCODER_H_ */
